import os
import json

# 加载配置(绝对路径)
script_dir = os.path.dirname(os.path.abspath(__file__))
CONFIG_JSON_PATH = os.path.join(script_dir, 'config.json')


def load_config():
    """
    解析config.json

    :return: 路径字典
    """
    with open(CONFIG_JSON_PATH, 'r') as f:
        return json.load(f)


# 只加载一次配置
paths = load_config()

# 使用已加载的配置来定义文件夹路径
LOGS_DIR = os.path.join(script_dir, paths['logs_dir'])
ASC_FILE_DIR = os.path.join(script_dir, paths['asc_file_dir'])
TEMP_FILE_DIR = os.path.join(script_dir, paths['temp_file_dir'])
SAVE_FILE_DIR = os.path.join(script_dir, paths['save_file_dir'])
UI_CONFIG = paths['ui_config']

# PATHS_MAP = {
#     'LOGS_DIR': LOGS_DIR,
#     'ASC_FILE_DIR': ASC_FILE_DIR,
#     'TEMP_FILE_DIR': TEMP_FILE_DIR,
#     'SAVE_FILE_DIR': SAVE_FILE_DIR
# }
